package dao

import "new/models"

func GetAllmedical_record() ([]models.Medical_record, int64, error) {
	var medical_recordData []models.Medical_record
	var total int64
	//从数据库表medical_record中找到主码mno在对其进行操作，以下同理
	err := db.Table("medical_record").Order("mno ASC").Count(&total).Find(&medical_recordData).Error
	return medical_recordData, total, err
}
func Delmedical_record(mno int) error {
	var medical_record []models.Medical_record
	err := db.Table("medical_record").Where("mno = ?", mno).Delete(&medical_record).Error
	return err
}
func Updatemedical_record(medical_record models.Medical_record) error {
	err := db.Table("medical_record").Where("mno = ?", medical_record.Mno).Updates(&medical_record).Error
	return err
}
func Addmedical_record(medical_record models.Medical_record) error {
	err := db.Table("medical_record").Create(&medical_record).Error
	return err
}
